home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.netins.net!isac!gg
- From: gg@isac.hces.com (Greg Goodrich)
- Subject: Re: What is &Variable (declared as: char Variable[10])?
- Message-ID: <1996Feb26.211807.28858@isac.hces.com>
- Organization: Health Care Expert Systems
- X-Newsreader: TIN [version 1.2 PL2]
- References: <4gqpa1$3h9@alcor.usc.edu>
- Date: Mon, 26 Feb 1996 21:18:07 GMT
-
- Abu Wawda (wawda@alcor.usc.edu) wrote:
- : I'm having trouble understanding what the address of a static array
- : is. For example, if I declare a variable called myarray as:
- : char myarray[10];
- : then what could &myarray possibly mean? myarray is not a pointer, so
- : &myarray could not possibly be the address of the variable myarray
- : (like it would be if I did char* myarray and then asked for &myarray).
-
- : Functions such as scanf() allow the following:
-
- : char myarray[10];
-
- : scanf("%s",&myarray);
-
- : but I don't understand what scanf() could possibly be taking in the
- : second parameter. It can't be: char** since myarray is not a
- : pointer. I CAN understand how the following would work:
-
- This is because C treats the occurrence of array names as the address of
- the array. Therefore the following are equivalent:
-
- scanf("%s", myarray);
- scanf("%s", &myarray);
-
- The thing is, the address is implied when you use an array name. This
- is not so for pointers. I am not sure why C was incorporated in this
- way. In my humble opinion, it would make it easier and clearer to force
- the programmer to put the & in front of array names, the same as you
- have to do for any other storage class.
-
- Greg.
- --
- _______________________________________
- Greg Goodrich - gg@hces.com
- Software Engineer
- PACE Health Management Systems
-